package com.jiegui.sms.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jiegui.common.annotation.Log;
import com.jiegui.common.core.controller.BaseController;
import com.jiegui.common.core.domain.AjaxResult;
import com.jiegui.common.enums.BusinessType;
import com.jiegui.sms.domain.SmsInterfaceRequest;
import com.jiegui.sms.service.SmsInterfaceRequestService;
import com.jiegui.common.utils.poi.ExcelUtil;
import com.jiegui.common.core.page.TableDataInfo;

/**
 * 短信发送记录Controller
 * 
 * @author wuqicheng
 * @date 2021-12-30
 */
@RestController
@RequestMapping("/sms/smsInterfaceRequest")
public class SmsInterfaceRequestController extends BaseController
{
    @Resource
    private SmsInterfaceRequestService smsInterfaceRequestService;

    /**
     * 查询短信发送记录列表
     */
    @PreAuthorize("@ss.hasPermi('sms:smsInterfaceRequest:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmsInterfaceRequest smsInterfaceRequest)
    {
        startPage();
        List<SmsInterfaceRequest> list = smsInterfaceRequestService.selectSmsInterfaceRequestList(smsInterfaceRequest);
        return getDataTable(list);
    }

    /**
     * 导出短信发送记录列表
     */
    @PreAuthorize("@ss.hasPermi('sms:smsInterfaceRequest:export')")
    @Log(title = "短信发送记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SmsInterfaceRequest smsInterfaceRequest)
    {
        List<SmsInterfaceRequest> list = smsInterfaceRequestService.selectSmsInterfaceRequestList(smsInterfaceRequest);
        ExcelUtil<SmsInterfaceRequest> util = new ExcelUtil<SmsInterfaceRequest>(SmsInterfaceRequest.class);
        return util.exportExcel(list, "短信发送记录数据");
    }

    /**
     * 获取短信发送记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('sms:smsInterfaceRequest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(smsInterfaceRequestService.selectSmsInterfaceRequestById(id));
    }

    /**
     * 新增短信发送记录
     */
    @PreAuthorize("@ss.hasPermi('sms:smsInterfaceRequest:add')")
    @Log(title = "短信发送记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmsInterfaceRequest smsInterfaceRequest)
    {
        return toAjax(smsInterfaceRequestService.insertSmsInterfaceRequest(smsInterfaceRequest));
    }

    /**
     * 修改短信发送记录
     */
    @PreAuthorize("@ss.hasPermi('sms:smsInterfaceRequest:edit')")
    @Log(title = "短信发送记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmsInterfaceRequest smsInterfaceRequest)
    {
        return toAjax(smsInterfaceRequestService.updateSmsInterfaceRequest(smsInterfaceRequest));
    }

    /**
     * 删除短信发送记录
     */
    @PreAuthorize("@ss.hasPermi('sms:smsInterfaceRequest:remove')")
    @Log(title = "短信发送记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(smsInterfaceRequestService.deleteSmsInterfaceRequestByIds(ids));
    }
}
